package com.hzhc.controller.index;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CntrLogService;
import com.hzhc.service.TrainPlanService;
import com.hzhc.utils.ResultUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dongcy
 * @date 2024/6/14 11:19
 * @description IndexController
 */
@RestController
@RequestMapping("/index")
@RequiredArgsConstructor
public class IndexController extends BaseController {

    private final TrainPlanService trainPlanService;
    private final CntrLogService logService;

    /**
     * 首页-班列数+发运箱数+到达箱数
     * @return
     */
    @RequestMapping("/getIndexTop")
    public ResultUtil<JSONObject> getIndexTop(){
        JSONObject obj = trainPlanService.getIndexTop();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 首页-当日班列信息
     * @return
     */
    @RequestMapping("/getIndexCenter")
    public ResultUtil<JSONObject> getIndexCenter(){
        JSONObject obj = trainPlanService.getIndexCenter();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 首页 饼图(空箱+大小箱)
     * @return
     */
    @RequestMapping("/getIndexBottomPie")
    public ResultUtil<JSONObject> getIndexBottomPie(){
        JSONObject obj = trainPlanService.getIndexBottomPie();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 首页-货代排行(按箱量)
     * @return
     */
    @RequestMapping("/getIndexCompanyRank")
    public ResultUtil<JSONObject> getIndexCompanyRank(){
        JSONObject obj = trainPlanService.getIndexCompanyRank();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 首页-发运+到达个数
     * @return
     */
    @RequestMapping("/getIndexColumn")
    public ResultUtil<JSONArray> getIndexColumn(){
        JSONArray obj = trainPlanService.getIndexColumn();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 首页-饼图-今日吞吐量
     * @return
     */
    @RequestMapping("/getTodayTPS")
    public ResultUtil<JSONArray> getTodayTPS(){
        JSONArray obj = logService.getTodayTPS();
        return ResultUtil.build(obj,ResultUtilCodeEnum.SUCCESS);
    }


}
